package com.itheima.dao;

import com.itheima.pojo.OrderSetting;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author xiaycbstart
 * @create 2019 12 23 20:39
 */
public interface OrderSettingDao {
    /**
     * 预约数据插入
     *
     * @param orderSetting
     * @return
     * @author xiayc
     */
    @Insert("insert into t_ordersetting (id,orderDate,number,reservations) values (null,#{orderDate},#{number},#{reservations})")
    void add(OrderSetting orderSetting);

    @Select("select count(*) from t_ordersetting where orderDate = #{orderDate} ")
    long findCountByOrderDate(Date orderDate);

    @Update("update t_ordersetting set number =#{number} where orderDate = #{orderDate}")
    void editNumberByOrderDate(OrderSetting orderSetting);

    @Select("select * from t_ordersetting where orderDate between #{begin} and #{end}")
    List<OrderSetting> getOrderSettingByMonth(Map map);

    @Select("select * from t_ordersetting where orderDate = #{date}")
    OrderSetting findByOrderDate(Date date);

    @Update("update t_ordersetting set reservations =#{reservations} where orderDate = #{orderDate}")
    void editReservationsByOrderDate(OrderSetting orderSetting);
}
